package com.crealth.model;

import java.io.Serializable;

import com.alibaba.fastjson.JSONObject;

public class ConsumerWorkModel implements Serializable {
	private static final long serialVersionUID = 40854741L;
	
	private int id;
	private int consumerID;
	private int workType;
	private String companyName;
	private int duty;
	private int monthlySalary;
	private int workTime;
	private int payForm; 
	private int socialSecurityBase;
	private int reservedFundsBase;
	
	public ConsumerWorkModel() {
		companyName = "";
		workType = -1;
		duty = -1;
		monthlySalary = -1;
		workTime = -1;
		payForm = -1;
		socialSecurityBase = -1;
		reservedFundsBase = -1;
	}
	
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public int getConsumerID() {
		return consumerID;
	}
	public void setConsumerID(int consumerID) {
		this.consumerID = consumerID;
	}
	public int getWorkType() {
		return workType;
	}
	public void setWorkType(int workType) {
		this.workType = workType;
	}
	public String getCompanyName() {
		return companyName;
	}
	public void setCompanyName(String companyName) {
		this.companyName = companyName;
	}
	public int getDuty() {
		return duty;
	}
	public void setDuty(int duty) {
		this.duty = duty;
	}
	public int getMonthlySalary() {
		return monthlySalary;
	}
	public void setMonthlySalary(int monthlySalary) {
		this.monthlySalary = monthlySalary;
	}
	public int getWorkTime() {
		return workTime;
	}
	public void setWorkTime(int workTime) {
		this.workTime = workTime;
	}
	public int getPayForm() {
		return payForm;
	}
	public void setPayForm(int payForm) {
		this.payForm = payForm;
	}
	public int getSocialSecurityBase() {
		return socialSecurityBase;
	}
	public void setSocialSecurityBase(int socialSecurityBase) {
		this.socialSecurityBase = socialSecurityBase;
	}
	public int getReservedFundsBase() {
		return reservedFundsBase;
	}
	public void setReservedFundsBase(int reservedFundsBase) {
		this.reservedFundsBase = reservedFundsBase;
	}
	
	public void parseFromJson(JSONObject jsonData) {
		if (jsonData.containsKey("professionType")) {
			this.workType = jsonData.getIntValue("professionType");
		}
		if (jsonData.containsKey("comName")) {
			this.companyName = jsonData.getString("comName");
		}
		if (jsonData.containsKey("position")) {
			this.duty = jsonData.getIntValue("position");
		}
		if (jsonData.containsKey("monthlySalary")) {
			this.monthlySalary = jsonData.getIntValue("monthlySalary");
		}
		if (jsonData.containsKey("workTime")) {
			this.workTime = jsonData.getIntValue("workTime");
		}
		if (jsonData.containsKey("payType")) {
			this.payForm = jsonData.getIntValue("payType");
		}
		if (jsonData.containsKey("sbBase")) {
			this.socialSecurityBase = jsonData.getIntValue("sbBase");
		}
		if (jsonData.containsKey("gjjBase")) {
			this.reservedFundsBase = jsonData.getIntValue("gjjBase");
		}
	}
	
	public JSONObject toJSONObject() {
		JSONObject jsonObj = new JSONObject();
		if (workType >= 0) {
			jsonObj.put("professionType", workType);
		}
		if (companyName != null && companyName.length() > 0) {
			jsonObj.put("comName", companyName);
		}
		if (duty >= 0) {
			jsonObj.put("position", duty);
		}
		if (monthlySalary >= 0) {
			jsonObj.put("monthlySalary", monthlySalary);
		}
		if (workTime >= 0) {
			jsonObj.put("workTime", workTime);
		}
		if (payForm >= 0) {
			jsonObj.put("payType", payForm);
		}
		if (socialSecurityBase >= 0) {
			jsonObj.put("sbBase", socialSecurityBase);
		}
		if (reservedFundsBase >= 0) {
			jsonObj.put("gjjBase", reservedFundsBase);
		}
		
		return jsonObj;
	}

}
